package com.github.shiqiyue.app.config.redis;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/***
 * redisson配置
 * @author wenyao.wu
 * @date 2019/9/7
 */
@Configuration
@EnableConfigurationProperties(RedissonProperties.class)
public class RedissonConfiguration {

    @Bean(destroyMethod = "shutdown")
    RedissonClient redissonClient(RedissonProperties redissonConfig) {
        Config config = new Config();
        config.useSingleServer().setAddress(redissonConfig.getAddress()).setPassword(redissonConfig.getPassword());
        RedissonClient client = Redisson.create(config);
        return client;
    }
}
